type GetGetterReturns<T> = {
	[P in keyof T]: T[P] extends FnType ? ReturnType<T[P]> : never
}

type PickVaildModuleValue<T, K extends string> = [T] extends [never] ? never : {
	[P in keyof T as[T[P]] extends [never] ? never : K extends keyof T[P] ? P : never]: T[P]
}
type GetDispatch<T> = {
	<K extends keyof T> (action: K, payload?: T[K]): Promise<unknown>
}
type GetMutationParams<T extends FnType> = Parameters<T> extends [unknown, ...infer arg] ? arg : never

type GetCommit<T> = T extends { [key: string]: FnType } ? {
	<K extends keyof T> (type: K, ...params: GetMutationParams<T[K]>): void
} : never

export type GetModuleValues<T, Key extends string> = T[keyof T] extends { [P in Key]: infer getters } ? getters : never


export type GetStates<T> = {
	[P in keyof T]: T[P] extends { 'state': infer states } ? states : never
}

export type GetGetters<T> = GetGetterReturns<UnionToInterSection<GetModuleValues<T, 'getters'>>>

export type GetDispatchs<T> = GetDispatch<UnionToInterSection<GetModuleValues<PickVaildModuleValue<T, 'actions'>, 'actions'>>>

export type GetCommits<T> = GetCommit<UnionToInterSection<GetModuleValues<T, 'mutations'>>>

